package com.shiro.common.entity;

import com.shiro.common.entity.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: dengpeng
 * Date: 2018/7/5
 * Time: 10:29
 * Description: 用户
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "user")
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class User extends BaseEntity {

    /**密码*/
    @Column(name = "password",nullable = false,length = 50)
    private String password;

    /**角色*/
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "user_role",
                    joinColumns = {@JoinColumn(name = "user_id")},
                    inverseJoinColumns = {@JoinColumn(name = "role_id")})
    private List<Role> roleList;

    /**操作日志*/
    @OneToMany(fetch = FetchType.LAZY,mappedBy = "user")
    private List<Log> logList;

}
